<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title>Client management page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="CSS/bootstrap.css" rel="stylesheet">
        <link href="CSS/bootstrap-responsive.css" rel="stylesheet">
        <script src="JS/jquery.js"></script>
        <script src="JS/bootstrap.js"></script>
        <script src="JS/javascriptclient.js"></script>        
        <script>
            function loadInnerContent() {
                $("#headerofpage").load("headerofpage.html");
                $.ajax({
                    url: 'CheckClientLoggedInServlet',
                    success : function(text){
                        responsestate = text.substring(0,7);
                        response = text.substring(7);
                        if (responsestate == "success") {
                            document.getElementById("replyField").innerHTML = "<h6>" + response + "</h6> <label></label> ";
                        } else {
                            $(location).attr("href","index.jsp");
                        }
                    }
                });            
                window.setTimeout("setActive()", 500);
            }
            function setActive() {
                $("#homemenu").addClass("active");
            }
            function leftHomeMenuPressed() {
                $("#contentPlace").load("elementscl.html #homeText", function() {
                });
                removeAllMenuClasses();
                $("#leftHomeMenu").addClass("active");
            }
            function leftHelpMenuPressed() {
                $("#contentPlace").load("elementscl.html #helpText");
                removeAllMenuClasses();
                $("#leftHelpMenu").addClass("active");
            }
            function leftMyInfoMenuPressed() {
                $("#contentPlace").load("elementscl.html #myInfoClient", function() {
                    updateMyInfoTable();
                });
                removeAllMenuClasses();
                $("#leftMyInfoMenu").addClass("active");
            }
            function removeAllMenuClasses() {
            $("#leftHomeMenu").removeClass("active");
            $("#leftAgreementsMenu").removeClass("active");
            $("#leftPaymentsMenu").removeClass("active");
            $("#leftMyInfoMenu").removeClass("active");
            $("#leftHelpMenu").removeClass("active");
            }
            function leftPaymentsMenuPressed() {
                removeAllMenuClasses();
                $("#leftPaymentsMenu").addClass("active");
                $.ajax ({
                    url: "GetClientPaymentsServlet",
                    error: function() {$(location).attr("href","index.jsp");  },
                    success: function(text) {
                        var response = text;
                        if (response == "failure") $(location).attr("href","index.jsp");
                        if (response == "nodata") document.getElementById("contentPlace").innerHTML = "<div class=\"alert\"><h3><strong>Sorry!</strong></h3>    <h5>You didn't make any payments.</h5>    If not. Please inform us about Your payments.</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​"
                        if (response != "failure" && response != "nodata") {
                        var jsonGot = JSON.parse(response);
                        makePaymentsFormElement(jsonGot);                            
                        }
                    }
                })
            }
            function leftAgreementsMenuPressed() {
                removeAllMenuClasses();
                $("#leftAgreementsMenu").addClass("active");
                $.ajax( {
                    url: "GetClientAgreementsServlet",
                    error: function() {$(location).attr("href","index.jsp");  },
                    success: function(text) {
                        var response = text;
                        if (response == "failure") $(location).attr("href","index.jsp");
                        if (response == "nodata") document.getElementById("contentPlace").innerHTML = "<div class=\"alert\"><h3><strong>Sorry!</strong></h3>    <h5>You don't have any agreements.</h5>    If not. Please inform us about Your agreements.</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​"
                        if (response != "failure" && response != "nodata") {
                        var jsonGot = JSON.parse(response);
                        makeAgreementsFormElement(jsonGot);
                        }
                   }
                });
            }
        </script>

    </head>
    <body onload="loadInnerContent(), leftHomeMenuPressed()">
        <div id="headerofpage">
        </div>

        <div class="row-fluid">
            <div class="span2" id="leftColumn">
                <ul class="nav nav-list">
                    <li onclick="leftHomeMenuPressed(); return false;" id="leftHomeMenu"><a href="">Home</a></li>
                    <li class="nav-header">MY DOCUMENTS</li>
                    <li onclick="leftAgreementsMenuPressed(); return false;" id="leftAgreementsMenu"><a href="">Agreements</a></li>
                    <li onclick="leftPaymentsMenuPressed(); return false;" id="leftPaymentsMenu"><a href="">Payments</a></li>
                    <li class="nav-header">PERSONAL INFO</li>
                    <li onclick="leftMyInfoMenuPressed(); return false;" id="leftMyInfoMenu"><a href="">My info</a></li>
                    <li onclick="leftHelpMenuPressed(); return false;" id="leftHelpMenu"><a href="">Help</a></li>
                </ul>
            </div>
            <div class="span8" id="centerColumn">
                <div id="contentPlace">
                    <div id="outputBodyPlace"></div>
                </div>

            </div>
            <div class="span2" id="rightColumn">
                <div id="replyField"></div>
                <button class="btn btn-primary" type="button" id="logoutButton" onclick="logoutClient()" data-loading-text="Exiting...">Logout</button>
                <div id="forInformers"></div>
            </div>
        </div>
    </body>
</html>
